<template>
  <el-button @click="cancel" size="small">{{$t('back')}}</el-button>
</template>
<script>

/**
 * 表单返回，二次验证有没修改
 */
export default {
  name: 'CancelBtn',
  props: {
    form: {
      type: [Object, String, Number, Array],
      default: null,
    },
    formClone: {
      type: [Object, String, Number, Array],
      default: null,
    }
  },
  data() {
    return {

    }
  },
  watch: {

  },
  mounted() {

  },
  methods: {
    cancel() {
      if (JSON.stringify(this.form) != JSON.stringify(this.formClone)) {
        this.$confirm(this.$t("areYouReturn"), this.$t("warmReminder"),
          { confirmButtonText: this.$t("ok"), cancelButtonText: this.$t("cancel"), type: "warning", })
          .then(() => {
            this.$emit('cancel');
          })
          .catch(() => { });
      } else {
        this.$emit('cancel')
      }
    }
  }
}
</script>

<style lang="scss">
</style>
